package com.ruoyi.web.controller.wb;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wb.domain.WbClassifyYearContent;
import com.ruoyi.wb.service.IWbClassifyYearContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 维保年度类目二级表Controller
 * 
 * @author ruoyi
 * @date 2024-11-18
 */
@RestController
@RequestMapping("/system/WbClassifyYearContent")
public class WbClassifyYearContentController extends BaseController
{
    @Autowired
    private IWbClassifyYearContentService wbClassifyYearContentService;

    /**
     * 查询维保年度类目二级表列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WbClassifyYearContent wbClassifyYearContent)
    {
        startPage();
        List<WbClassifyYearContent> list = wbClassifyYearContentService.selectWbClassifyYearContentList(wbClassifyYearContent);
        return getDataTable(list);
    }

    /**
     * 导出维保年度类目二级表列表
     */
    @Log(title = "维保年度类目二级表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WbClassifyYearContent wbClassifyYearContent)
    {
        List<WbClassifyYearContent> list = wbClassifyYearContentService.selectWbClassifyYearContentList(wbClassifyYearContent);
        ExcelUtil<WbClassifyYearContent> util = new ExcelUtil<WbClassifyYearContent>(WbClassifyYearContent.class);
        util.exportExcel(response, list, "维保年度类目二级表数据");
    }

    /**
     * 获取维保年度类目二级表详细信息
     */
    @GetMapping(value = "/{classifyYearContentId}")
    public AjaxResult getInfo(@PathVariable("classifyYearContentId") Long classifyYearContentId)
    {
        return success(wbClassifyYearContentService.selectWbClassifyYearContentByClassifyYearContentId(classifyYearContentId));
    }

    /**
     * 新增维保年度类目二级表
     */
    @Log(title = "维保年度类目二级表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WbClassifyYearContent wbClassifyYearContent)
    {
        return toAjax(wbClassifyYearContentService.insertWbClassifyYearContent(wbClassifyYearContent));
    }

    /**
     * 修改维保年度类目二级表
     */
    @Log(title = "维保年度类目二级表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WbClassifyYearContent wbClassifyYearContent)
    {
        return toAjax(wbClassifyYearContentService.updateWbClassifyYearContent(wbClassifyYearContent));
    }

    /**
     * 删除维保年度类目二级表
     */
    @Log(title = "维保年度类目二级表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classifyYearContentIds}")
    public AjaxResult remove(@PathVariable Long[] classifyYearContentIds)
    {
        return toAjax(wbClassifyYearContentService.deleteWbClassifyYearContentByClassifyYearContentIds(classifyYearContentIds));
    }
}
